{if !empty($nav_top_tiled_other)}
{loop $nav_top_tiled_other $other}
{if $other['is_system']}{php continue;}{/if}
<li ><a href="{$other['url']}"><i class="{$other['icon']}"></i><span>{$other['title']}</span></a></li>
{/loop}
{/if}
{if !empty($nav_top_tiled_other)}
{loop $nav_top_tiled_other $other}
{if !$other['is_system']}{php continue;}{/if}
{if $other['name'] == 'workorder' && (!permission_check_account_user('see_workorder') || !$_W['iscontroller'])}{php continue;}{/if}
{/loop}
{/if}

{template 'common/header-notice'}
<!-- 用户信息 -->
{template 'common/header-user'}
<!-- end用户信息 -->

<li class="dropdown-star {if !in_array(FRAME, array('account', 'wxapp'))}hidden{/if}">
	<a href="javascript:;" class="star-info">
		<img src="{if defined('IN_MODULE')}{if !empty($_W['current_module']['logo'])}{$_W['current_module']['logo']}{/if}{else}{if !empty($_W['account']['logo'])}{$_W['account']['logo']}{/if}{/if}" class="account-img" alt="">
		<span class="name text-over">{if defined('IN_MODULE')}{if !empty($_W['current_module']['title'])}{$_W['current_module']['title']}{/if}{else}{if !empty($_W['account']['name'])}{$_W['account']['name']}{/if}{/if}</span>
		<span class="caret"></span>
	</a>
	<div class="star-box">
		<div class="star-box__header">
			切换平台/应用
			<ul class="nav nav-tabs pull-right" role="tablist">
				<li role="presentation" class="" data-toggle="tooltip" data-placement="bottom" title="我的星标"><a href="#star-star" data-star="star" aria-controls="star-star" role="tab" data-toggle="tab"><i class="wi wi-star"></i></a></li>
				<li role="presentation" data-toggle="tooltip" data-placement="bottom" title="历史查看"><a href="#star-history" data-star="history" aria-controls="star-history" role="tab" data-toggle="tab"><i class="wi wi-waiting"></i></a></li>
				{if ACCOUNT_MANAGE_NAME_CLERK != $_W['highest_role']}<li role="presentation" data-toggle="tooltip" data-placement="bottom" title="所有平台"><a href="#star-platform" data-star="platform" aria-controls="star-platform" role="tab" data-toggle="tab"><i class="wi wi-platform"></i></a></li>{/if}
				<li role="presentation" data-toggle="tooltip" data-placement="bottom" title="所有应用"><a href="#star-modules" data-star="modules" aria-controls="star-modules" role="tab" data-toggle="tab"><i class="wi wi-apply"></i></a></li>
			</ul>
		</div>
		<div class="tab-content star-box__content">
			<div role="tabpanel" class="tab-pane" id="star-star"></div>
			<div role="tabpanel" class="tab-pane" id="star-history">2</div>
			<div role="tabpanel" class="tab-pane" id="star-platform">3</div>
			<div role="tabpanel" class="tab-pane" id="star-modules">4</div>
		</div>
	</div>
</li>

<script>
	$(function() {
		// 加border
		if($('.js-header-user').length && $($('.js-header-user')[0]).prev().length) {
			$($('.js-header-user')[0]).prev().after('<li><a class="header-user-border"></a></li>')
		}
		$('.dropdown-star .star-info').click(function(e) {
			$('.dropdown-star').toggleClass('active')
		})
		$('.dropdown').on('show.bs.dropdown', function () {
			$('.dropdown-star').removeClass('active')
		})
		$(document).click(function(e){
			if($(e.target).parents(".dropdown-star").length == 0){
				$('.dropdown-star').removeClass('active')
			}
		});
		$('#updateCache').on('click', function(){
			$('.loader').show();
			$.post('./index.php?c=system&a=updatecache&do=updatecache', {}, function(data) {
				$('.loader').hide();
				util.message('更新缓存成功！', '', 'success');
			})
		});
		test = function(e) {
			console.log(e)
			return true;
		}
		$('.dropdown-star [data-toggle="tab"]').on('show.bs.tab', function (e) {
			var star = $(e.target).data('star')
			window.localStorage.setItem('we7StarHeader', $(e.target).data('star'))
			var menuList = {
				star: {
					apiUrl: './index.php?c=account&a=display&do=list_star&',
					name: '星标',
					url: './home.php#/mystar'
				},
				history: {
					apiUrl: './index.php?c=account&a=display&do=history&',
					name: '历史',
					url: './home.php#/history'
				},
				platform: {
					apiUrl: './index.php?c=account&a=display&do=list&type=all',
					name: '平台',
					url: './home.php#/platform'
				},
				modules: {
					apiUrl: './index.php?c=module&a=display&do=own&',
					name: '应用',
					url: './home.php#/modules'
				}
			}
			$('#star-' + star).html('<div class="loading star-header-list"><i class="fa fa-spinner fa-spin"></i>加载中</div>')
			$.get(menuList[star]['apiUrl'], {
				limit_num: 5,
				page: 1
			} , function(res) {
				if(res.message && res.message.errno == 0) {
					let html = '<div class="star-header-list">'
					let list = res.message.message.list ||  res.message.message
					for(var i in list) {
						var item = list[i];
						html = html + '<a href="' + item.switchurl + '" class="star-header-item star-item--account">' +
							'<img src="'+ item.logo +'"  alt="" class="star-header-item__logo ' + (item.list_type == 'account' ? 'account-img' : 'module-img') + '"/>' +
							'<div class="star-header-item__info">' +
							'<div class="star-header-item__name text-over">' + (item.list_type == 'account' ? item.name : item.title) + '</div>' +
							'<div class="star-header-item__desc text-over">' + (item.list_type == 'account' ? (item.type_name + (item.level ? ('/' + item.level) : '')) : ('所属平台：' + (item.default_account ? item.default_account.name : ''))) + '</div>' +
							'</div>' +
							'<div class="star-header-item__go">' +
							'<i class="wi wi-angle-right"></i>' +
							'</div>' +
							'</a>'
					}
					html = html + '</div>' +
						'<div class="star-go"><a href="'+ menuList[star]['url'] + '">查看全部' + menuList[star]['name'] + '</a></div>'
					$('#star-' + star).html(html)
				}
			}, 'json')
		})
		var headerStar = window.localStorage.getItem('we7StarHeader');
		if(!headerStar) {
			headerStar = 'star';
		}
		if($('.dropdown-star').length && !$('.dropdown-star').hasClass('.hide')) {
			$('[data-star="' + headerStar + '"]').tab('show')
		}
	})
</script>
